import 'package:json_annotation/json_annotation.dart';

part 'order_list.g.dart';

@JsonSerializable()
class OrderList {
  final Model model;

  OrderList(this.model);

  factory OrderList.fromJson(Map<String, dynamic> json) => _$OrderListFromJson(json);

  Map<String, dynamic> toJson() => _$OrderListToJson(this);
}

@JsonSerializable()
class Model {
  final List<Order> content;
  final int number;
  final bool last;

  Model(this.content, this.number, this.last);

  factory Model.fromJson(Map<String, dynamic> json) => _$ModelFromJson(json);

  Map<String, dynamic> toJson() => _$ModelToJson(this);
}

@JsonSerializable()
class Order {
  final int id;
  final String code;
  final String orderStatus; // 订单状态 UNPAID, PAYING, PAID, CANCELLED
  final String orderStatusStr;
  final String deliveryStatus; // 快递状态 NONE, PARTIALLY, CONFIRMING, CONFIRMED
  final String deliveryStatusStr;
  final String createTime;
  final String payTime;
  final String deliveryTime;
  final String payMode;
  final List<Product> orderDetails;
  final double amount;
  final double paidPointCoins;
  final double paidAmount;
  final double paidFreight;
  final int storeId;
  final int referStoreId;
  final String postcode;
  final String memo;

  Order(
    this.id,
    this.code,
    this.orderStatus,
    this.orderStatusStr,
    this.deliveryStatus,
    this.deliveryStatusStr,
    this.createTime,
    this.payTime,
    this.deliveryTime,
    this.payMode,
    this.orderDetails,
    this.amount,
    this.paidAmount,
    this.paidPointCoins,
    this.paidFreight,
    this.storeId,
    this.referStoreId,
    this.postcode,
    this.memo,
  );

  factory Order.fromJson(Map<String, dynamic> json) => _$OrderFromJson(json);

  Map<String, dynamic> toJson() => _$OrderToJson(this);
}

@JsonSerializable()
class Product {
  final int id;
  final int productId;
  final String productName;
  final String productImage;
  final int quantity;
  final String modelDesc;

  Product(
    this.id,
    this.productId,
    this.productName,
    this.productImage,
    this.quantity,
    this.modelDesc,
  );

  factory Product.fromJson(Map<String, dynamic> json) => _$ProductFromJson(json);

  Map<String, dynamic> toJson() => _$ProductToJson(this);
}
